package creationPattern.Factory.Factory_02.service.impl;

import com.alibaba.fastjson.JSON;
import creationPattern.Factory.Factory_02.entity.AwardInfo;
import creationPattern.Factory.Factory_02.entity.ResponseResult;
import creationPattern.Factory.Factory_02.entity.SmallGiftInfo;
import creationPattern.Factory.Factory_02.service.IFreeGoods;

import java.util.UUID;

public class SmallGiftService implements IFreeGoods {
    /**
     * 发奖品
     * @return
     */
    @Override
    public ResponseResult sendFreeGoods(AwardInfo awardInfo) {
        SmallGiftInfo giftInfo = new SmallGiftInfo();
        giftInfo.setUserPhone(awardInfo.getExtMap().get("phone"));
        giftInfo.setUserName(awardInfo.getExtMap().get("userName"));
        giftInfo.setAddress(awardInfo.getExtMap().get("address"));
        giftInfo.setOrderId(String.valueOf(UUID.randomUUID()));

        System.out.println("向用户发送小礼品" + JSON.toJSON(giftInfo));

        return new ResponseResult("200","发送小礼品成功",giftInfo);
    }
}
